﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LongQuanWeb.App_Code;

namespace LongQuanWeb.Admin
{
    public partial class QQInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((this.Session["username"] == null) || (this.Session["username"].ToString() == string.Empty))
            {
                base.Response.Write("<font color=#ff0000 style='FONT-SIZE: 12px'>对不起,您没足够权限访问此页!!</font><br>");
                base.Response.Write("<a href='Login.aspx' target=_top style='FONT-SIZE: 12px'>重新登陆</a><br>");
                base.Response.End();
            }
            if (!IsPostBack)
            {
                base.Response.Write("<script>parent.window.document.getElementById( 'lbl_title').innerHTML='客服修改'; </script>");
                string strSql = "select * from [QQInfo] where ID=1";
                DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
                this.txt_QQ1.Text = dt.Rows[0]["QQ1"].ToString().Trim();
                this.txt_QQ2.Text = dt.Rows[0]["QQ2"].ToString().Trim();
                this.txt_QQ3.Text = dt.Rows[0]["QQ3"].ToString().Trim();
                this.txt_QQ4.Text = dt.Rows[0]["QQ4"].ToString().Trim();
                this.txt_name1.Text = dt.Rows[0]["Name1"].ToString().Trim();
                this.txt_name2.Text = dt.Rows[0]["Name2"].ToString().Trim();
                this.txt_name3.Text = dt.Rows[0]["Name3"].ToString().Trim();
                this.txt_name4.Text = dt.Rows[0]["Name4"].ToString().Trim();
            }
        }

        protected void btn_Add_Click(object sender, EventArgs e)
        {
            string sql = "Update [QQInfo] set QQ1='" + this.txt_QQ1.Text.Trim() + "',QQ2='" + this.txt_QQ2.Text.Trim() + "',QQ3='" + this.txt_QQ3.Text.Trim() + "',QQ4='" + this.txt_QQ4.Text.Trim() + "',Name1='" + this.txt_name1.Text.Trim() + "',Name2='" + this.txt_name2.Text.Trim() + "',Name3='" + this.txt_name3.Text.Trim() + "',Name4='" + this.txt_name4.Text.Trim() + "' where ID=1";
            if (DbHelperSQL.ExecuteSql(sql) > 0)
            {
                base.Response.Write("<script>alert('修改成功');window.location='QQInfo.aspx'</script>");
            }
            else
            {
                base.Response.Write("<script>alert('修改失败');</script>");
            }
        }
    }
}
